// pages/personal/personal.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    sickName: "",
    patientId: "",
    idCard: "",
    birthday: "",
    address: "",
    phone: "",
    show:"show"
  },

  //记录查询
  registerLog: function (e) {
    wx.navigateTo({
      url: '/pages/registerLog/registerLog?type=' + e.currentTarget.dataset.type
    })
  },

  payLog: function(e) {
    wx.navigateTo({
      url: '/pages/registerLog/registerLog?type=' + e.currentTarget.dataset.type
    })
  },

  updatePatientInfo: function(e) {
    wx.navigateTo({
      url: '../zhuce/zhuce?type=' + e.currentTarget.dataset.type,
    })
  },

  updatePatientInfoMsg: function(e) {
    wx.navigateTo({
      url: '../improveInfo/improveInfo',
    })
  },

  addVisitCard: function () {
    app.globalData.userInfo = null
    wx.navigateTo({
      url: '../index/index',
    })
  },

  goto_index:function(res){
    wx.showModal({
      title: '提示',
      content: '是否确认退出',
      complete: (res) => {
        if (res.cancel) {
          
        }
    
        if (res.confirm) {
          this.data.sickName = "",
          this.data.patientId = "",
          this.data.idCard = "",
          this.data.birthday = "",
          this.data.address = "",
          this.data.phone = "",
          app.globalData.userInfo = null,
          wx.redirectTo({
            url: '../index/index',
          })
        }
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(app.globalData.userInfo.name)
    var that = this;
    if (app.globalData.userInfo.name == ""){
      that.setData({
        show:"show"
      })
    } else {
      that.setData({
        sickName: app.globalData.userInfo.name,
        patientId: app.globalData.userInfo.patientId,
        idCard: app.globalData.userInfo.idCard,
        birthday: app.globalData.userInfo.birthday,
        address: app.globalData.userInfo.address,
        phone: app.globalData.userInfo.phone,
        show: "hidden"
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})